module QuestionsHelper
  def fields_for_answer(answer, &block)
    prefix = answer.new_record? ? 'new' : 'existing'
    fields_for("question[#{prefix}_answer_attributes][]", answer, &block)
  end
  
  def add_answer_field_link(name)
    link_to_function name do |page|
      page.insert_html :bottom, :answers, :partial => 'answer', :object => Answer.new
    end
  end
end